{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Dynamic Process: Robustness to the Belief Updating Parameter (with CW) (C.2)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2021-02-09T13:45:39.550486Z", "start_time": "2021-02-09T13:45:33.326091Z" } }, "outputs": [], "source": [ "import pandas as pd\n", "from poisson_approval import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2021-02-09T13:45:39.568440Z", "start_time": "2021-02-09T13:45:39.559531Z" } }, "outputs": [], "source": [ "N_SAMPLES = 10000\n", "N_MAX_EPISODES = 1000" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2021-02-09T13:45:39.623686Z", "start_time": "2021-02-09T13:45:39.575419Z" } }, "outputs": [], "source": [ "update_ratios = {\n", " '1': 1,\n", " '0.5': 0.5,\n", " 'one_over_log_log_t_plus_fourteen': one_over_log_log_t_plus_fourteen,\n", " 'one_over_log_t_plus_one': one_over_log_t_plus_one,\n", " 'one_over_sqrt_t': one_over_sqrt_t,\n", " 'one_over_t': one_over_t, \n", "}" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2021-02-09T13:45:39.635723Z", "start_time": "2021-02-09T13:45:39.628741Z" } }, "outputs": [], "source": [ "rand_profile = RandConditional(\n", " RandProfileHistogramUniform(n_bins=1), \n", " test=is_condorcet, n_trials_max=None\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Condorcet consistency:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2021-02-09T13:45:44.236406Z", "start_time": "2021-02-09T13:45:39.638714Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
ApprovalPluralityAnti-plurality
Belief updating parameter
10.9993850.66160.547106
0.50.9997650.67210.527511
one_over_log_log_t_plus_fourteen0.9998980.67350.531112
one_over_log_t_plus_one0.9997290.67000.492881
one_over_sqrt_t1.0000000.65990.462096
one_over_t0.9995000.66450.446902
\n", "
" ], "text/plain": [ " Approval Plurality Anti-plurality\n", "Belief updating parameter \n", "1 0.999385 0.6616 0.547106\n", "0.5 0.999765 0.6721 0.527511\n", "one_over_log_log_t_plus_fourteen 0.999898 0.6735 0.531112\n", "one_over_log_t_plus_one 0.999729 0.6700 0.492881\n", "one_over_sqrt_t 1.000000 0.6599 0.462096\n", "one_over_t 0.999500 0.6645 0.446902" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "table_cond = pd.DataFrame()\n", "table_cond.index.name = 'Belief updating parameter'\n", "for update_ratio_name, update_ratio in update_ratios.items():\n", " results = monte_carlo_fictitious_play(\n", " factory=rand_profile,\n", " n_samples=N_SAMPLES,\n", " n_max_episodes=N_MAX_EPISODES,\n", " voting_rules=VOTING_RULES,\n", " init='random_tau',\n", " perception_update_ratio=update_ratio,\n", " monte_carlo_settings=[\n", " MCS_FREQUENCY_CW_WINS,\n", " ],\n", " file_save='sav/perception_update_%s_with_CW.sav' % update_ratio_name,\n", " )\n", " for voting_rule in VOTING_RULES:\n", " table_cond.loc[update_ratio_name, voting_rule] = float(results[voting_rule]['mean_frequency_cw_wins'])\n", "table_cond" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.7" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": true, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }